home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Sleep Deprivation 1.0 Source / Sleep Deprivation ƒ / sd wipes ƒ / Mr. Do.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-12  |  3.9 KB  |  189 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Mr. Do.c
  4.  
  5. Purpose:    This module handles clearing the screen in a funky
  6.             manner.  See the comments below for more details.
  7.             
  8.  
  9. Sleep Deprivation -- graphic effects on sleep
  10. Copyright (C) 1993 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define        BoxSize    4
  32. #define CorrectTime 1
  33.  
  34. void MrDo(GrafPtr, Pattern*);
  35.  
  36. /* 25 regions, in a 5 x 5 grid.  Go around to each region in a spiral pattern
  37.    and alternatively scroll it up or down. */
  38.    
  39. void MrDo(GrafPtr thePtr, Pattern *thePattern)
  40. {
  41.     int            x, y;
  42.     int            vgap,hgap;
  43.     Rect        theRect, dest;
  44.     Rect        scrollsource, scrolldest;
  45.     Rect        bounds[25];
  46.     Boolean        everyOther;
  47.     int            width,height;
  48.     
  49.     width=thePtr->portRect.right-thePtr->portRect.left;
  50.     height=thePtr->portRect.bottom-thePtr->portRect.top;
  51.     
  52.     vgap=height/5;
  53.     hgap=width/5;
  54.     
  55.     for (x=0; x<25; x++)
  56.     {
  57.         switch (x)
  58.         {
  59.             case 0:
  60.             case 1:
  61.             case 2:
  62.             case 3:
  63.             case 4:
  64.                 bounds[x].top=0;
  65.                 break;
  66.             case 15:
  67.             case 16:
  68.             case 17:
  69.             case 18:
  70.             case 5:
  71.                 bounds[x].top=vgap;
  72.                 break;
  73.             case 14:
  74.             case 23:
  75.             case 24:
  76.             case 19:
  77.             case 6:
  78.                 bounds[x].top=vgap*2;
  79.                 break;
  80.             case 13:
  81.             case 22:
  82.             case 21:
  83.             case 20:
  84.             case 7:
  85.                 bounds[x].top=vgap*3;
  86.                 break;
  87.             case 12:
  88.             case 11:
  89.             case 10:
  90.             case 9:
  91.             case 8:
  92.                 bounds[x].top=vgap*4;
  93.                 break;
  94.         }
  95.         switch (x)
  96.         {
  97.             case 0:
  98.             case 15:
  99.             case 14:
  100.             case 13:
  101.             case 12:
  102.                 bounds[x].left=0;
  103.                 break;
  104.             case 1:
  105.             case 16:
  106.             case 23:
  107.             case 22:
  108.             case 11:
  109.                 bounds[x].left=hgap;
  110.                 break;
  111.             case 2:
  112.             case 17:
  113.             case 24:
  114.             case 21:
  115.             case 10:
  116.                 bounds[x].left=hgap*2;
  117.                 break;
  118.             case 3:
  119.             case 18:
  120.             case 19:
  121.             case 20:
  122.             case 9:
  123.                 bounds[x].left=hgap*3;
  124.                 break;
  125.             case 4:
  126.             case 5:
  127.             case 6:
  128.             case 7:
  129.             case 8:
  130.                 bounds[x].left=hgap*4;
  131.                 break;
  132.         }
  133.         bounds[x].left+=thePtr->portRect.left;
  134.         bounds[x].top+=thePtr->portRect.top;
  135.         bounds[x].bottom=bounds[x].top+vgap;
  136.         bounds[x].right=bounds[x].left+hgap;
  137.     }
  138.     
  139.     for (y=0; y<25; y++)
  140.     {        
  141.         if (y%2)   /* these scroll up */
  142.         {
  143.             scrollsource=bounds[y];
  144.             scrollsource.top+=BoxSize;
  145.             scrolldest=scrollsource;
  146.             OffsetRect(&scrolldest,0,-BoxSize);
  147.             
  148.             dest=bounds[y];
  149.             dest.top=dest.bottom-BoxSize;
  150.             
  151.             for (x=bounds[y].bottom-bounds[y].top-BoxSize; x>0; x-=BoxSize)
  152.             {
  153.                 StartTiming();
  154.                 CopyBits(&(thePtr->portBits), &(thePtr->portBits),
  155.                         &scrollsource, &scrolldest, 0, 0L);
  156.                 FillRect(&dest, *thePattern);
  157.  
  158.                 if (everyOther)
  159.                     TimeCorrection(CorrectTime);
  160.                 everyOther=!everyOther;
  161.             }
  162.         }
  163.         else    /* these scroll down */
  164.         {
  165.             scrollsource=bounds[y];
  166.             scrollsource.bottom-=BoxSize;
  167.             scrolldest = scrollsource;
  168.             OffsetRect(&scrolldest, 0, BoxSize);
  169.             
  170.             dest=bounds[y];
  171.             dest.bottom=dest.top+BoxSize;
  172.             
  173.             for(x = bounds[y].bottom-bounds[y].top-BoxSize; x > 0; x -= BoxSize)
  174.             {
  175.                 StartTiming();
  176.                 CopyBits(&(thePtr->portBits), &(thePtr->portBits),
  177.                         &scrollsource, &scrolldest, 0, 0L);
  178.                 FillRect(&dest, *thePattern);
  179.  
  180.                 if (everyOther)
  181.                     TimeCorrection(CorrectTime);
  182.                 everyOther=!everyOther;
  183.             }
  184.         }
  185.  
  186.         FillRect(&bounds[y], *thePattern);
  187.     }
  188. }
  189.